﻿using System.Web.Mvc;
using System.Web.Routing;
using BSU.GraduateWork.Web.Binders;
using BSU.GraduateWork.Web.Models;
using BSU.GraduateWork.Web.Routes;

namespace BSU.GraduateWork.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "SolutionStep",                                              // Route name
                "Solution/{dimension}/{action}",                           // URL with parameters
                new { controller = "Solution", dimension = "3D", action = "Step3" },
                new { dimension = new DimensionRouteConstraint(), }// Parameter defaults
            );

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

            

            routes.MapRoute(
                "SolutionDetails",                                              // Route name
                "Solution/{dimension}/{action}/{id}",                           // URL with parameters
                new { controller = "Solution", dimension = "3D", action = "Display", id = "" },
                new { dimension = new DimensionRouteConstraint(), }// Parameter defaults
            );

            
        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            ModelBinders.Binders[typeof(SolutionModel)] = new SolutionModelBinder();
            ModelBinders.Binders[typeof(Solution2DModel)] = new Solution2DModelBinder();
        }
    }
}